import React from 'react';
import ReactDOM from 'react-dom';
import { createStore, applyMiddleware } from 'redux';
import createSagaMiddleware from 'redux-saga';

import rootSaga from './saga/saga';
import Counter from './component/counter';

const sagaMiddleware = createSagaMiddleware();
const store = createStore(
    applyMiddleware(sagaMiddleware)
)
sagaMiddleware.run(rootSaga)

const action = type => store.dispatch({type})

function render(){
    ReactDOM.render(
        <Counter
        value = {store.getState()}
        onIncrement={()=>action('INCREMENT')}
        onDecrement = {() => action('DECREMENT')}
        onIncrementAsync = {() => action('INCREMENT_ASYNC')}
        />,
        document.getElementById('root')
    )
}